/**
 * 
 */
package jp.ekasi.pms.ui.grid.util;

import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.jface.viewers.ColumnLabelProvider;

/**
 * @author sumari
 *
 */
public class EAttributeTypeColumnLabelProvider extends ColumnLabelProvider {
	
	/**
	 * 
	 */
	private EAttribute attribute;
	
	/**
	 * 
	 * @param attribute
	 */
	public EAttributeTypeColumnLabelProvider(EAttribute attribute) {
		this.attribute = attribute;
	}
	
	@Override
	public String getText(Object element) {
		if(element==null) {
			return null;
		}		
		String text = null;
		Object value = ((EObject)element).eGet(attribute);
		if(value != null) {
			text = EcoreUtil.convertToString(attribute.getEAttributeType(), value);
		}
		return text;
	}
	
}
